/*
 * @Date: 2023-02-24 11:40:05
 * @LastEditTime: 2023-03-07 17:20:25
 * @FilePath: /hash-guess-game/src/views/arena/mix.ts
 * 介绍:
 */
import toast from "@@/components/rework/toast";
import { t } from "@@/hooks/useI18n";
import { i18n } from "@@/language/index";
import { parseNumber } from "@@/utils/tools/tools";
//@ts-ignore
const { t: $t } = i18n.global;
export const typeEnum = {
  /**幸运赛车 */
  "3": {
    title: t("xing-yun-sai-che"),
    submitVerify: (coin: Coin, amount: number): boolean => {
      if (amount < 1 && Math.floor(amount * 100) % 10 === 0) {
        toast.text(`${coin.code} ${$t("xiao-shu-di-er-wei-bu-neng-wei")}: 0`);
        return false;
      }
      if (Math.floor(amount) % 10 === 0) {
        toast.text(`${$t("ge-wei-shu-bu-neng-wei")}: 0`);
        return false;
      }
      return true;
    },
    /**验证成功失败 */
    isSucceed: (txid: string, amount: number) => {
      console.info("输入的amount--", amount, "输入的txid--", txid);
      if (amount < 1) {
        amount = Number(parseNumber(amount * 100, 4));
      }
      const txidNumberStr = txid.replace(/[^1-9]/g, "");
      /**最后一位txid */
      const txidLast = Number(txidNumberStr.slice(txidNumberStr.length - 1));
      /**最后一位amount */
      const amountLast = Math.floor(amount) % 10;
      console.info("最后一位amount--", amountLast, "最后一位txid--", txidLast);
      if (amountLast === txidLast) return true;
      return false;
    },
  },
  /**奇偶猜猜猜 */
  "2": {
    title: t("qi-ou-cai-cai-cai"),
    submitVerify: (coin: Coin, amount: number): boolean => true,
    /**验证成功失败 */
    isSucceed: (txid: string, amount: number): boolean => {
      const txidNumberStr = txid.replace(/[^1-8]/g, "");
      if (amount < 1) {
        amount = Number(parseNumber(amount * 100, 4));
      }
      /**txid最后一位数字 */
      const txidLast = Number(txidNumberStr.slice(txidNumberStr.length - 1));
      /**amount最后一位数字 */
      const amountLast = Math.floor(amount) % 10;
      /**txid单或双 */
      const txidOddOrEven: 0 | 1 = (txidLast % 2) as any;
      /**amount单或双 */
      const amountOddOrEven: 0 | 1 = (amountLast % 2) as any;
      console.info(
        "txid--",
        txid,
        "txidNumber--",
        txidNumberStr,
        "txidLast--",
        txidLast,
        "amount--",
        amount,
        "amountLast--",
        amountLast,
        "txid单双--",
        txidOddOrEven,
        "amount单双--",
        amountOddOrEven
      );
      if (txidOddOrEven === amountOddOrEven) return true;
      return false;
    },
  },
};
